import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from '@/views/layout/myIndex.vue'
import Login from '@/views/login/myIndex.vue'
import Home from '@/views/home/myHome.vue'
// 管理异步加载
const Product = ()=>import('@/views/product/myIndex.vue')
const List = ()=>import('@/views/product/list/myIndex.vue')
const Category = ()=>import('@/views/product/category/myIndex.vue')

// 订单异步加载
const Order = ()=>import('@/views/order/myIndex.vue')
const OrderList = ()=>import('@/views/order/list/myIndex.vue')
const Collect = ()=>import('@/views/order/collect/myIndex.vue')

// 广告异步加载
const Advert = ()=>import('@/views/advert/myIndex.vue')
const AdvertList = ()=>import('@/views/advert/list/myIndex.vue')

Vue.use(VueRouter)

const routes = [
  {
    path:'/',
    component:Layout,
    children:[
      {
         path:'/',
         name:'home',
         component:Home,
      },
      {
         path:'/product',//产品管理
         name:'product',
         component:Product,
         children:[
          {
          path:'list',//访问路径：/product/list
          name:'list',
          component:List
          },
          {
          path:'category',//访问路径：/product/category
          name:'category',
          component:Category
          },
         ]
      },
      {
         path:'/order',//订单管理
         name:'order',
         component:Order,
         children:[
          {
          path:'order-List',
          name:'order-List',
          component:OrderList
          },
          {
          path:'collect',
          name:'collect',
          component:Collect
          },
         ]
      },
      {
         path:'/advert',//广告管理
         name:'advert',
         component:Advert,
         children:[
          {
          path:'advert-list',
          name:'advert-list',
          component:AdvertList
          },
         ]
      }
    ]
  },
  {
    path:'/login',
    name:'login',
    component:Login,
  },
]

const router = new VueRouter({
  routes
})

export default router
